package xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

import xixirupan.tmgp.tencent.com.vmeim.R;
import xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.model.LiveListBaen;

/**
 * Created by lenovo on 2016/10/20.
 */

public class Item4IndexAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    List<LiveListBaen> liveList; Context context;LayoutInflater inflater;
     public Item4IndexAdapter(List<LiveListBaen> liveList, Context context, LayoutInflater inflater)
     {
         this.inflater =inflater;
         this.liveList =liveList;
         this.context =context;
     }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item4_video_index, parent, false);
        VideoHolder holder =new VideoHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof VideoHolder)
    {
        LiveListBaen liveListBaen = liveList.get(position);
        String headImg = liveListBaen.getHeadImg();
        String imgURL = liveListBaen.getImgURL();
        String nickName = liveListBaen.getNickName();
        String title = liveListBaen.getTitle();


        Glide.with(context).load(imgURL).into(((VideoHolder) holder).imageView);
      //  Glide.with(context).load(headImg).into(((VideoHolder) holder).imageView_icon);
        ((VideoHolder) holder).imageView_icon.setImageURI(headImg);
        ((VideoHolder) holder).textView_title.setText(title);
        ((VideoHolder) holder).textView_name.setText(nickName);

    }
    }

    @Override
    public int getItemCount() {
        return liveList.size();
    }
    class VideoHolder extends RecyclerView.ViewHolder
    {
        ImageView imageView;
        TextView textView_title;
        TextView textView_name;
        SimpleDraweeView imageView_icon;
        ImageView imageView_add;
        public VideoHolder(View itemView) {
            super(itemView);
           imageView = (ImageView) itemView.findViewById(R.id.video_item4_index);
           textView_title = (TextView) itemView.findViewById(R.id.title_name_video);
            textView_name = (TextView) itemView.findViewById(R.id.author_name);
          imageView_icon = (SimpleDraweeView) itemView.findViewById(R.id.icon_author);
          imageView_add = (ImageView) itemView.findViewById(R.id.imageView_add);
        }
    }
}
